# $Id: CMakeLists.txt 13 2010-11-23 03:19:26Z cubicool $

PROJECT(cairocks)

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/etc/")

IF(NOT WIN32)
	SET(CMAKE_C_FLAGS "-W -Wall -Wno-unused")
	SET(CMAKE_CXX_FLAGS "-W -Wall -Wno-unused")
ENDIF(NOT WIN32)

FIND_PACKAGE(Cairo REQUIRED)
FIND_PACKAGE(JPEG)
FIND_PACKAGE(GIF)

SET(CAIROCKS_SRC_FILES
	"src/distance-field.c"
	"src/emboss.c"
	"src/gaussian-blur.c"
	"src/gif-surface.c"
	"src/invert.c"
	"src/map-path-onto.c"
	"src/rounded.c"
	"src/surface-from-jpeg.c"
)

SET(CAIROCKS_HEADER_FILE "src/cairocks.h")

INCLUDE_DIRECTORIES(
	src
	${CAIRO_INCLUDE_DIRS}
)

LINK_DIRECTORIES(
	${CAIRO_LIBRARY_DIRS}
)

SOURCE_GROUP("Header Files" FILES ${CAIROCKS_HEADER_FILE})
SOURCE_GROUP("Source Files" FILES ${CAIROCKS_SRC_FILES})

ADD_LIBRARY(cairocks SHARED ${CAIROCKS_HEADER_FILE} ${CAIROCKS_SRC_FILES})

TARGET_LINK_LIBRARIES(cairocks cairo)

IF(JPEG_FOUND)
	TARGET_LINK_LIBRARIES(cairocks ${JPEG_LIBRARIES})
	INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIRS})
	ADD_DEFINITIONS(-DCAIROCKS_JPEG_SUPPORT)
ENDIF(JPEG_FOUND)

IF(GIF_FOUND)
	TARGET_LINK_LIBRARIES(cairocks ${GIF_LIBRARIES})
	INCLUDE_DIRECTORIES(${GIF_INCLUDE_DIR})
	ADD_DEFINITIONS(-DCAIROCKS_GIF_SUPPORT)
ENDIF(GIF_FOUND)

INSTALL(TARGETS cairocks
	ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
	LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
	RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)

INSTALL(
	FILES ${CAIROCKS_HEADER_FILE}
	DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)

CONFIGURE_FILE(
	"${CMAKE_CURRENT_SOURCE_DIR}/etc/uninstall.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
	IMMEDIATE @ONLY
)

ADD_CUSTOM_TARGET(uninstall
	"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
)

